/*
参数说明：
alertShow-弹出框参数{
showmsg-服务器弹窗提示
msg-服务器提示内容
}
*/
<template>
  <div>
    <alert v-model="alertShow.showmsg" :title="'提示'" @on-show="onShow" @on-hide="onHide">{{alertShow.msg}}</alert>
    <div style="font-size: 0">
      <img :src="signLogo" width="100%" height="100%" @click="SignFn" />
    </div>
    <div v-for="item in activityList" style="padding-top: 10px;font-size: 0">
      <a  @click="luckFn(item)"><img :src="item.banner" width="100%" height="100%"/></a>
    </div>
  </div>
</template>
<script>
  import { Flexbox, FlexboxItem, Alert } from 'vux'
  import * as urls from '../../../api/urls'

  export default {
    components: {
      Flexbox,
      FlexboxItem,
      Alert
    },
    mounted: function () {
      this.LinkData = ''
      this.getActImgList()
      this.weixinfn45()
//      this.$nextTick(function () {
//        this.$root.$el.__vue__.$data.index = 0
//        this.$root.$el.__vue__.$data.isSel1 = true
//        this.$root.$el.__vue__.$data.isSel2 = false
//        this.$root.$el.__vue__.$data.isSel3 = false
//        this.$root.$el.__vue__.$data.isSel4 = false
//      })
    },
    data () {
      return {
        alertShow: {
          showmsg: false,
          msg: ''
        },
        activityList: [],
        signLogo: '',
        LinkData: ''
      }
    },
    methods: {
      getActImgList () {
        let that = this
        this.http(urls.preIndex, {}, function (res) {
          if (res.status === 100) {
            if (res.data.activitys.length !== 0) {
              that.activityList = res.data.activitys
            }
            that.signLogo = res.data.signLogo
          } else {
            that.alertShow.showmsg = true
            that.alertShow.msg = res.errMsg
          }
        }, function (res) {
          that.alertShow.showmsg = true
          that.alertShow.msg = res
        })
      },
      luckFn (obj) {
        let userId = window.sessionStorage.getItem('userId')
        window.location.href = '/api/wxAuth/go/Luck_id=' + obj.id + '&userId=' + userId
//        this.$router.push({
//          path: '/Luck',
//          query: {
//            activityId: obj.id
//          }
//        })
//        this.$router.go(1)
      },
      SignFn () {
//        this.$router.push({
//          path: '/SignDay'
//        })
//        this.$router.go(1)
        let userId = window.sessionStorage.getItem('userId')
        window.location.href = '/api/wxAuth/go/SignDay_userId=' + userId
      },
      onShow () {
        // 弹窗出现时触发
      },
      onHide () {
        // 弹窗关闭时触发
      },
      weixinfn45 () {
        let userId = window.sessionStorage.getItem('userId')
        let url = window.location.origin
        let link = url + '/api/wxAuth/index?type=t1' + '&uid=' + userId
        this.weixin(url, link)
      }
    }
  }
</script>
<style>
  .table_activit{
    -moz-border-radius:25px;
    border-radius:25px;
    border: 1px solid #999999;
    height: 40px
  }
  .table_activit_tr{
    float: left;
    padding: 10px
  }
</style>
